package cn.hx.malluser.utils;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MetaDataFill implements MetaObjectHandler {

    /** 注册新用户时，自动填充以下字段 */
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("status", 1, metaObject);
        this.setFieldValByName("createTime", new Date(), metaObject);
        this.setFieldValByName("gender", 0, metaObject);
        this.setFieldValByName("birthday", new Date(), metaObject);
        this.setFieldValByName("integration", 0, metaObject);
        this.setFieldValByName("growth", 0, metaObject);
        this.setFieldValByName("historyIntegration", 0, metaObject);
        this.setFieldValByName("icon", "assets/images/avatar/defaultAvatar.jpg", metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {

    }
}
